package com.javaee.weixin.xiaochengxu.dto;

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.javaee.weixin.xiaochengxu.tools.MD5Util;
import com.fasterxml.jackson.annotation.JsonInclude.Include;


@JsonInclude(value=Include.NON_NULL)
public class PaymentDto implements Serializable {
	
	String appId;
	String timeStamp;
	String nonceStr;
	@JsonProperty("package")
	String packagz;
	String signType;
	String paySign;
	
	public void setPaySign(String key) {
		StringBuilder sb = new StringBuilder();
		if (StringUtils.isNotBlank(this.appId)) {
			sb.append("appId=" + this.appId);
		}
		if (StringUtils.isNotBlank(this.nonceStr)) {
			sb.append("&nonceStr=" + this.nonceStr);
		}
		if (StringUtils.isNotBlank(this.packagz)) {
			sb.append("&package=" + this.packagz);
		}
		if (StringUtils.isNotBlank(this.signType)) {
			sb.append("&signType=" + this.signType);
		}
		if (StringUtils.isNotBlank(this.timeStamp)) {
			sb.append("&timeStamp=" + this.timeStamp);
		}
		sb.append("&key=" + key);

		this.paySign = MD5Util.getInstance().compile(sb.toString()).toUpperCase();
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(String timeStamp) {
		this.timeStamp = timeStamp;
	}

	public String getNonceStr() {
		return nonceStr;
	}

	public void setNonceStr(String nonceStr) {
		this.nonceStr = nonceStr;
	}

	public String getPackagz() {
		return packagz;
	}

	public void setPackagz(String packagz) {
		this.packagz = packagz;
	}

	public String getSignType() {
		return signType;
	}

	public void setSignType(String signType) {
		this.signType = signType;
	}

	public String getPaySign() {
		return paySign;
	}
	
}
